# import ddddocr
# ocr = ddddocr.DdddOcr()
# with open(r'C:\Users\Administrator\Desktop\123.jpg', 'rb') as f:
#     img_bytes = f.read()
# res = ocr.classification(img_bytes)
# print(res)
import re
import httpx


def func1():
    url = 'https://www.51tracking.com/loginaction'
    headers = {

        'Accept': '*/*',
        'Accept-Encoding': 'gzip, deflate, br',
        'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
        'Connection': 'keep-alive',
        'Content-Length': '66',
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        # 'Cookie': 'normalTr0019=VStQJwI3AD1QbF00VzxRcQIyB3YMPlxnAGwEOFYxB2EHNgdlVTwBEVd7CHlUfQloBGEBPwEjXn5SJQB0UWcHP1U%2BUGACcABqUC9dbFdjUWoCOgdiDD5cZABkBDFWOQdnByAHflUnASRXeQhtVCEJYgRqAXABO15wUjAAN1E9B2RVaFAnAn4AclB9XTxXI1EgAn8HOwx%2BXDQAdwQ6VioHNAdnB2pVYwFoVzoIO1QwCWkENgFnATZeNFJlADRRawcyVWZQZwI3ADZQNF1sV2FRMQIxBzYMP1w2AGMEOFY8B3IHLgdwVXEBI1drCGtUOAliBGABNQFsXj1SdQBhUUAHIlUDUG0CPQAgUGRdO1cpUXECMgd2DDxccgAo; expires=Sat, 19-Feb-2022 06:30:28 GMT; Max-Age=259200; path=/; domain=.51tracking.com',
        'Host': 'www.51tracking.com',
        'Origin': 'https://www.51tracking.com',
        'Referer': 'https://www.51tracking.com/login',
        'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'Sec-Fetch-Dest': 'empty',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Site': 'same-origin',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
        'X-Requested-With': 'XMLHttpRequest',

    }
    param = {
        'type': 'login',
        'email': '279891479@qq.com',
        'password': 'LELE20080713',
        'forward': ''
    }
    response = httpx.post(url, headers=headers, data=param).headers
    # print(response,type(response))
    cookie = re.findall(r"set-cookie', '(.*?)'\), \('", str(response))[0]
    # print(cookie)
    return cookie


import requests

headers = {
    'Accept': '*/*',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
    'Connection': 'keep-alive',
    'Content-Length': '142',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'Cookie': '{}'.format(func1()),
    'Host': 'my.51tracking.com',
    'Origin': 'https://my.51tracking.com',
    'Referer': 'https://my.51tracking.com/tools/newParcelNew.php?lang=cn&formId=0',
    'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-origin',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
    'X-Requested-With': 'XMLHttpRequest',
}

data = {
    'type': 'add-single-number',
    'number': '93001109247000000036305564',
    'express': 'usps',
    'special': 'none',
    'order_id': '',
    'order_create_time': '',
    'comment': '',
    'phone': '',
    'email': '',
    'lang': 'cn',
}
res = httpx.post(headers=headers, url='https://my.51tracking.com/data/data-api.php', data=data)
print(res.text)


'''

'''


